# @Time : 2021/2/14 14:18
# @Author : Li Kunlun
# @Description :

import numpy as np

TARGET_PHRASE = 'You get it!'  # target DNA
TARGET_ASCII = np.fromstring(TARGET_PHRASE, dtype=np.uint8)  # convert string to number
# [ 89 111 117  32 103 101 116  32 105 116  33]
print(TARGET_ASCII)

print("--------------------")
ASCII_BOUND = [32, 127]
pop_size = 10
DNA_size = len(TARGET_ASCII)
# 11
print(DNA_size)
print(np.random.randint(*ASCII_BOUND, size=(pop_size, DNA_size)).astype(np.int8))

print("---------sum(axis=1)测试-----------")
# pop = np.random.randint(*DNA_bound, size=(pop_size, DNA_size)).astype(np.int8)
pop = np.array([(89, 111, 117, 32, 103, 101, 116, 32, 105, 116, 33),(89, 111, 117, 32, 103, 101, 116, 32, 105, 116, 33)])
# (2, 11)
print(pop.shape)
match_count = (pop == TARGET_ASCII).sum(axis=1)
# [11 11]
print(match_count)
